package gui;

import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.RoundRectangle2D;
import java.rmi.RemoteException;

import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import rmi.Session;

public class GUIHomeLeft extends JPanel{
	
	private static final long serialVersionUID = 1L;
	public static final int EXAM_SHOWING = 0;
	public static final int RANDOM_SHOWING = 1;
	public static final int MARK_SHOWING = 2;
	public static final int ANSWER_SHOWING = 3;
	private int whatIsShowing;
	
	public GUIHomeLeft() {
		setOpaque(false);
		setBorder(new EmptyBorder(5, 5, 0, 5));
		setLayout(new BorderLayout());
	}
	
	public void DoingRandom(Session session){
		removeAll();
		GUIQuestionRandom displayrd = new GUIQuestionRandom(session);
		add(displayrd,BorderLayout.CENTER);
		whatIsShowing = RANDOM_SHOWING;
	}
	
	
	public void DoingExam(Session session){
		removeAll();
		GUIQuestion display = new GUIQuestion(session);
		add(display,BorderLayout.CENTER);
		try {
			display.setQuestions(session.getQuestions());
		} catch (RemoteException e) {
			e.printStackTrace();
		}
		whatIsShowing = EXAM_SHOWING;
	}
	
	public void DoingMark(Session session){
		removeAll();
		GUIMark displaymark = new GUIMark(session);
		add(displaymark,BorderLayout.CENTER);
		whatIsShowing = MARK_SHOWING;
	}
	
	public int getWhatIsShowing(){
		return whatIsShowing;
	}

	@Override
	protected void paintComponent(Graphics g) {
		Graphics2D g2d;
		g2d = (Graphics2D) g;
		
		g2d.setRenderingHint(
			    RenderingHints.KEY_ANTIALIASING,
			    RenderingHints.VALUE_ANTIALIAS_ON);
		
		RoundRectangle2D roundedRectangle = new RoundRectangle2D.Float(0, 0, this.getWidth()-1, this.getHeight()-1, 15, 15);
		
		g2d.setColor(new Color(250, 250, 250, 255));
		g2d.fill(roundedRectangle);
		
		g2d.setColor(new Color(100, 100, 100, 150));
		g2d.draw(roundedRectangle);
		g2d.setRenderingHint(
			    RenderingHints.KEY_ANTIALIASING,
			    RenderingHints.VALUE_ANTIALIAS_DEFAULT);
		super.paintComponent(g);
	}
	
	
}
